home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / include / coff / powerpc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  5.6 KB  |  200 lines

  1. /* Basic coff information for the PowerPC
  2.  *
  3.  * Based on coff/rs6000.h, coff/i386.h and others.
  4.  *
  5.  * Initial release: Kim Knuttila (krk@cygnus.com)
  6.  */
  7.  
  8. /********************** FILE HEADER **********************/
  9.  
  10. struct external_filehdr {
  11.   char f_magic[2];    /* magic number            */
  12.   char f_nscns[2];    /* number of sections        */
  13.   char f_timdat[4];    /* time & date stamp        */
  14.   char f_symptr[4];    /* file pointer to symtab    */
  15.   char f_nsyms[4];    /* number of symtab entries    */
  16.   char f_opthdr[2];    /* sizeof(optional hdr)        */
  17.   char f_flags[2];    /* flags            */
  18. };
  19.  
  20. #define    FILHDR    struct external_filehdr
  21. #define    FILHSZ    20
  22.  
  23. /* Bits for f_flags:
  24.  *    F_RELFLG    relocation info stripped from file
  25.  *    F_EXEC        file is executable (no unresolved external references)
  26.  *    F_LNNO        line numbers stripped from file
  27.  *    F_LSYMS        local symbols stripped from file
  28.  *    F_AR32WR    file has byte ordering of an AR32WR machine (e.g. vax)
  29.  */
  30.  
  31. #define F_RELFLG    (0x0001)
  32. #define F_EXEC        (0x0002)
  33. #define F_LNNO        (0x0004)
  34. #define F_LSYMS        (0x0008)
  35.  
  36. /* extra NT defines */
  37. #define PPCMAGIC       0760         /* peeked on aa PowerPC Windows NT box */
  38. #define DOSMAGIC       0x5a4d       /* from arm.h, i386.h */
  39. #define NT_SIGNATURE   0x00004550   /* from arm.h, i386.h */
  40.  
  41. /* from winnt.h */
  42. #define IMAGE_NT_OPTIONAL_HDR_MAGIC        0x10b
  43.  
  44. #define PPCBADMAG(x) ((x).f_magic != PPCMAGIC) 
  45.  
  46. /********************** AOUT "OPTIONAL HEADER" **********************/
  47.  
  48. typedef struct 
  49. {
  50.   char     magic[2];        /* type of file                */
  51.   char    vstamp[2];        /* version stamp            */
  52.   char    tsize[4];        /* text size in bytes, padded to FW bdry*/
  53.   char    dsize[4];        /* initialized data "  "        */
  54.   char    bsize[4];        /* uninitialized data "   "        */
  55.   char    entry[4];        /* entry pt.                */
  56.   char     text_start[4];        /* base of text used for this file */
  57.   char     data_start[4];        /* base of data used for this file */
  58. }
  59. AOUTHDR;
  60.  
  61. #define AOUTSZ 28
  62. #define AOUTHDRSZ 28
  63.  
  64. /********************** SECTION HEADER **********************/
  65.  
  66. struct external_scnhdr {
  67.   char        s_name[8];    /* section name                */
  68.   char        s_paddr[4];    /* physical address, aliased s_nlib */
  69.   char        s_vaddr[4];    /* virtual address                */
  70.   char        s_size[4];    /* section size                */
  71.   char        s_scnptr[4];    /* file ptr to raw data for section */
  72.   char        s_relptr[4];    /* file ptr to relocation        */
  73.   char        s_lnnoptr[4];    /* file ptr to line numbers        */
  74.   char        s_nreloc[2];    /* number of relocation entries        */
  75.   char        s_nlnno[2];    /* number of line number entries    */
  76.   char        s_flags[4];    /* flags                */
  77. };
  78.  
  79. #define    SCNHDR    struct external_scnhdr
  80. #define    SCNHSZ    40
  81.  
  82. /*
  83.  * names of "special" sections
  84.  */
  85. #define _TEXT    ".text"
  86. #define _DATA    ".data"
  87. #define _BSS    ".bss"
  88. #define _COMMENT ".comment"
  89. #define _LIB ".lib"
  90.  
  91. /********************** LINE NUMBERS **********************/
  92.  
  93. /* 1 line number entry for every "breakpointable" source line in a section.
  94.  * Line numbers are grouped on a per function basis; first entry in a function
  95.  * grouping will have l_lnno = 0 and in place of physical address will be the
  96.  * symbol table index of the function name.
  97.  */
  98. struct external_lineno {
  99.   union {
  100.     char l_symndx[4];    /* function name symbol index, iff l_lnno == 0 */
  101.     char l_paddr[4];    /* (physical) address of line number           */
  102.   } l_addr;
  103.   char l_lnno[2];    /* line number                               */
  104. };
  105.  
  106. #define    LINENO    struct external_lineno
  107. #define    LINESZ    6
  108.  
  109. /********************** SYMBOLS **********************/
  110.  
  111. #define E_SYMNMLEN    8     /* # characters in a symbol name       */
  112.  
  113. /* Allow the file name length to be overridden in the including file   */
  114. #ifndef E_FILNMLEN
  115. #define E_FILNMLEN    14
  116. #endif
  117.  
  118. #define E_DIMNUM    4     /* # array dimensions in auxiliary entry */
  119.  
  120. struct external_syment 
  121. {
  122.   union {
  123.     char e_name[E_SYMNMLEN];
  124.     struct {
  125.       char e_zeroes[4];
  126.       char e_offset[4];
  127.     } e;
  128.   } e;
  129.   char e_value[4];
  130.   char e_scnum[2];
  131.   char e_type[2];
  132.   char e_sclass[1];
  133.   char e_numaux[1];
  134. };
  135.  
  136. #define    SYMENT    struct external_syment
  137. #define    SYMESZ    18    
  138.  
  139. #define N_BTMASK    (0xf)
  140. #define N_TMASK        (0x30)
  141. #define N_BTSHFT    (4)
  142. #define N_TSHIFT    (2)
  143.   
  144. union external_auxent {
  145.   struct {
  146.     char x_tagndx[4];               /* str, un, or enum tag indx       */
  147.     union {
  148.       struct {
  149.     char  x_lnno[2];           /* declaration line number         */
  150.     char  x_size[2];           /* str/union/array size            */
  151.       } x_lnsz;
  152.       char x_fsize[4];               /* size of function                */
  153.     } x_misc;
  154.     union {
  155.       struct {                   /* if ISFCN, tag, or .bb           */
  156.     char x_lnnoptr[4];         /* ptr to fcn line #               */
  157.     char x_endndx[4];       /* entry ndx past block end        */
  158.       } x_fcn;
  159.       struct {                   /* if ISARY, up to 4 dimen.        */
  160.     char x_dimen[E_DIMNUM][2];
  161.       } x_ary;
  162.     } x_fcnary;
  163.     char x_tvndx[2];           /* tv index                        */
  164.   } x_sym;
  165.   
  166.   union {
  167.     char x_fname[E_FILNMLEN];
  168.     struct {
  169.       char x_zeroes[4];
  170.       char x_offset[4];
  171.     } x_n;
  172.   } x_file;
  173.   
  174.   struct {
  175.     char x_scnlen[4];               /* section length                  */
  176.     char x_nreloc[2];               /* # relocation entries            */
  177.     char x_nlinno[2];               /* # line numbers                  */
  178.     char x_checksum[4];           /* section COMDAT checksum          */
  179.     char x_associated[2];       /* COMDAT associated section index */
  180.     char x_comdat[1];           /* COMDAT selection number          */
  181.   } x_scn;
  182. };
  183.  
  184. #define    AUXENT    union external_auxent
  185. #define    AUXESZ    18
  186.  
  187. #define _ETEXT    "etext"
  188.  
  189. /********************** RELOCATION DIRECTIVES **********************/
  190.  
  191. struct external_reloc {
  192.   char r_vaddr[4];
  193.   char r_symndx[4];
  194.   char r_type[2];
  195. };
  196.  
  197. #define RELOC struct external_reloc
  198. #define RELSZ 10
  199.  
  200.